<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
ka-Map Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="kaLegend.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>ka-Map</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>kaLegend.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'kaLegend.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaLegend.html">kaLegend</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

	<a name="method_summary"><!-- --></a>
	<table border="1" cellpadding="3" cellspacing="0" width="100%">
		<tr bgcolor="#CCCCFF" class="TableHeadingColor">
			<td colspan=2>
				<font size="+2">
					<b>Method Summary</b>
				</font>
			</td>
		</tr>
	
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!kaLegend_collapseAll">kaLegend_collapseAll</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!kaLegend_expandAll">kaLegend_expandAll</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!kaLegend_expander">kaLegend_expander</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!kaLegend_opacityDown">kaLegend_opacityDown</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!kaLegend_opacityUp">kaLegend_opacityUp</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!kaLegend_queryOnClick">kaLegend_queryOnClick</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!kaLegend_queryOnMouseOut">kaLegend_queryOnMouseOut</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!kaLegend_queryOnMouseOver">kaLegend_queryOnMouseOver</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!kaLegend_toggleLayerQueryable">kaLegend_toggleLayerQueryable</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!kaLegend_toggleLayerVisibility">kaLegend_toggleLayerVisibility</a></b>()
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
	
	</table>
    <p>

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/**********************************************************************
 *
 * $Id: overview-summary-kaLegend.js.html,v 1.1 2006/03/15 15:56:58 pspencer Exp $
 *
 * purpose: a structured legend that supports grouped layers, visibility, 
 *          expand/collapse, and queryability
 *
 * author: Paul Spencer (pspencer<span class="attrib">@dmsolutions</span>.ca)
 *
 * The original kaLegend code was written by DM Solutions Group.  Lorenzo
 * Becchi and Andrea Cappugi contributed a bunch of code too!
 *
 * TODO:
 * 
 *   - drag and drop layer re-ordering would be nice, see script.alicio.us
 *
 **********************************************************************
 *
 * Copyright (c) 2005, DM Solutions Group Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 *
 **********************************************************************
 *
 * To use kaLegend:
 * 
 * 1) add a script tag to your page:
 * 
 * &lt;script type="text/javascript" src="kaLegend.js"&gt;&lt;/script&gt;
 *
 * 2) add a &lt;div&gt; element to your page to contain the legend.  The div must
 *    have a unique id:
 *
 * &lt;div id="legend"&gt;&lt;/div&gt;
 * 
 * 3) create a new instance of kaLegend and pass it the id of the div:
 * 
 * myKaLegend = new kaLegend( 'legend' );
 *
 * and that's it :)
 * 
 *****************************************************************************/</span>

<span class="comment">/******************************************************************************
 * kaLegend
 * 
 * internal class to handle the legend.
 * 
 * oKaMap - the ka-Map object to attach to.
 * szID - string, the id of a div that will contain the legend
 * bStatic - boolean, true to use static legends, false to use dynamic legends
 *
 *****************************************************************************/</span>
<span class="reserved">function</span> kaLegend(oKaMap, szID, bStatic) {
    <span class="reserved">this</span>.kaMap = oKaMap;
    <span class="reserved">this</span>.domObj = <span class="reserved">this</span>.kaMap.getRawObject(szID);
    <span class="reserved">this</span>.type = (bStatic)?<span class="literal">'static'</span>:<span class="literal">'dynamic'</span>;
    <span class="reserved">this</span>.expanders = [];
    <span class="reserved">this</span>.queryCBs = [];

    <span class="reserved">this</span>.urlBase = <span class="reserved">this</span>.kaMap.server;
    <span class="reserved">this</span>.urlBase += (<span class="reserved">this</span>.urlBase!=<span class="literal">''</span>&amp;&amp;<span class="reserved">this</span>.urlBase.substring(-1)!=<span class="literal">'/'</span>)?<span class="literal">''</span>:<span class="literal">'/'</span>;

    <span class="reserved">this</span>.showQueryCBs = true;    

    <span class="reserved">if</span> (<span class="reserved">this</span>.type == <span class="literal">'static'</span>) {
        <span class="reserved">this</span>.domImg = document.createElement( <span class="literal">'img'</span> );
        <span class="reserved">this</span>.domImg.src = <span class="reserved">this</span>.kaMap.aPixel.src;
        <span class="reserved">this</span>.domObj.appendChild( <span class="reserved">this</span>.domImg );
    } <span class="reserved">else</span> {
        <span class="reserved">this</span>.domObj.innerHTML = <span class="literal">'&amp;nbsp;'</span>;
    }

    <span class="reserved">this</span>.kaMap.registerForEvent( KAMAP_SCALE_CHANGED, <span class="reserved">this</span>, <span class="reserved">this</span>.update );
    <span class="reserved">this</span>.kaMap.registerForEvent( KAMAP_MAP_INITIALIZED, <span class="reserved">this</span>, <span class="reserved">this</span>.update );
    <span class="reserved">this</span>.kaMap.registerForEvent( KAMAP_LAYERS_CHANGED, <span class="reserved">this</span>, <span class="reserved">this</span>.draw );
    <span class="reserved">this</span>.kaMap.registerForEvent( KAMAP_LAYER_STATUS_CHANGED, <span class="reserved">this</span>, <span class="reserved">this</span>.update );
};

kaLegend.<span class="reserved">prototype</span>.update = <span class="reserved">function</span>(eventID)
{
    var url = <span class="literal">''</span>;
    <span class="reserved">if</span> (<span class="reserved">this</span>.type == <span class="literal">'static'</span>) {
        <span class="reserved">this</span>.domImg.src = <span class="literal">'legend.php?map='</span> + 
                          <span class="reserved">this</span>.kaMap.currentMap + 
                          <span class="literal">'&amp;scale='</span>+<span class="reserved">this</span>.kaMap.getCurrentScale();
    } <span class="reserved">else</span> {
        <span class="reserved">if</span> (eventID == KAMAP_MAP_INITIALIZED) {
            <span class="reserved">while</span>(<span class="reserved">this</span>.domObj.childNodes.length &gt; 0) {
                <span class="reserved">this</span>.domObj.removeChild(<span class="reserved">this</span>.domObj.childNodes[0]);
            } <span class="reserved">this</span>.draw();
                
        } <span class="reserved">else</span> <span class="reserved">if</span> (eventID == KAMAP_SCALE_CHANGED) {
            var oMap = <span class="reserved">this</span>.kaMap.getCurrentMap();
            var aLayers = oMap.getAllLayers();
            var s = <span class="reserved">this</span>.kaMap.getCurrentScale();
            <span class="reserved">for</span> (var i in aLayers) {
                var oLayer = aLayers[i];
                var oImg = <span class="reserved">this</span>.kaMap.getRawObject( <span class="literal">'legendImg_'</span> + oLayer.name);
                
                <span class="reserved">if</span> (oImg) {
                    <span class="comment">//added by Lorenzo</span>
                    var oParent = oImg.parentNode; 
                    var tId = oImg.id;
                    var tVisibility = oImg.visibility;
                    oParent.removeChild(oImg);
                    oImg = document.createElement(<span class="literal">'img'</span>);
                    oImg.id = tId;
                    oImg.title = tId;
                    oImg.visibility = tVisibility;
                    oImg.src = <span class="literal">'legend.php?map='</span> + 
                               <span class="reserved">this</span>.kaMap.currentMap + <span class="literal">'&amp;scale='</span> + s + <span class="literal">'&amp;g='</span> + 
                               oLayer.name;
                    oParent.appendChild(oImg);
                    expander = getRawObject(<span class="literal">'expander_'</span>+oLayer.name);
                    expander.expandable = oImg;
                    expander.expanded = true;
                    kaLegend_expander.apply( expander );
                }
                <span class="comment">//added by cappu</span>
                <span class="reserved">this</span>.setOnOffLayer(oLayer);
            }
        } <span class="reserved">else</span> <span class="reserved">if</span> (eventID == KAMAP_LAYER_STATUS_CHANGED) {
			var layer = arguments[1];
			<span class="reserved">for</span> (var i=0; i&lt;<span class="reserved">this</span>.queryCBs.length; i++) {
				<span class="reserved">if</span> (<span class="reserved">this</span>.queryCBs[i].oLayer == layer) {
					<span class="reserved">this</span>.queryCBs[i].checked = layer.visible;
				}
			}
		}
    }
};

<span class="comment">/**
 * legend.draw( szContents )
 *
 * render the contents of a legend template into a div
 */</span>
kaLegend.<span class="reserved">prototype</span>.draw = <span class="reserved">function</span>() {
<span class="comment">/*modificato da kappu non trova url corretto se non lo metto anche qui*/</span>
    <span class="reserved">this</span>.urlBase = <span class="reserved">this</span>.kaMap.server;
    <span class="reserved">this</span>.urlBase += (<span class="reserved">this</span>.urlBase!=<span class="literal">''</span>&amp;&amp;<span class="reserved">this</span>.urlBase.substring(-1)!=<span class="literal">'/'</span>)?<span class="literal">''</span>:<span class="literal">'/'</span>;

    var oMap = <span class="reserved">this</span>.kaMap.getCurrentMap();

    <span class="reserved">this</span>.expanders = [];
    <span class="reserved">this</span>.queryCBs = [];

    <span class="reserved">if</span> (<span class="reserved">this</span>.domObj.childNodes.length == 0) {
        <span class="reserved">this</span>.domObj.appendChild(<span class="reserved">this</span>.createHeaderHTML());
    }

    var aLayers = oMap.getAllLayers();
    <span class="reserved">for</span> (var i=(aLayers.length-1);i&gt;=0;i--) {
        <span class="reserved">if</span> (aLayers[i].kaLegendObj == null) {
            <span class="reserved">this</span>.createLayerHTML( aLayers[i] );
        } <span class="reserved">else</span> {
            try{<span class="reserved">this</span>.domObj.removeChild( aLayers[i].kaLegendObj );}
            catch(e){};
        }
    }

    <span class="reserved">for</span> (var i=(aLayers.length-1);i&gt;=0;i--) {
        <span class="reserved">this</span>.domObj.appendChild( aLayers[i].kaLegendObj );
    }

    <span class="reserved">if</span> (<span class="reserved">this</span>.kaMap.isIE4) {
        <span class="reserved">for</span>(var i=0; i&lt;<span class="reserved">this</span>.queryCBs.length; i++) {
            <span class="reserved">this</span>.queryCBs[i].checked = <span class="reserved">this</span>.queryCBs[i].oLayer.visible;
        }
    }
    <span class="reserved">return</span>;
};

kaLegend.<span class="reserved">prototype</span>.createHeaderHTML = <span class="reserved">function</span>() {
    var d, t, tb, tr, td, img;

    d = document.createElement( <span class="literal">'div'</span> );
    d.className = <span class="literal">'kaLegendTitle'</span>;

    t = document.createElement( <span class="literal">'table'</span> );

    t.setAttribute(<span class="literal">'width'</span>,<span class="literal">'226px'</span>);
    t.setAttribute(<span class="literal">'cellPadding'</span>, <span class="literal">"0"</span>);
    t.setAttribute(<span class="literal">'cellSpacing'</span>, <span class="literal">"0"</span>);
    t.setAttribute(<span class="literal">'border'</span>, <span class="literal">"0"</span>);

    tb = document.createElement( <span class="literal">"tbody"</span> );

    tr = document.createElement( <span class="literal">'tr'</span> );

    td = document.createElement( <span class="literal">'td'</span> );
    td.style.width=<span class="literal">'26px'</span>;
    img = document.createElement( <span class="literal">'img'</span> );
    img.src = <span class="literal">'images/expand.png'</span>;
    img.alt = <span class="literal">'expand all'</span>;
    img.title = <span class="literal">'expand all'</span>;
    img.kaLegend = <span class="reserved">this</span>;
    img.onclick = kaLegend_expandAll;
    td.appendChild( img );
    
    img = document.createElement( <span class="literal">'img'</span> );
    img.src = <span class="literal">'images/collapse.png'</span>;
    img.alt = <span class="literal">'collapse all'</span>;
    img.title = <span class="literal">'collapse all'</span>;
    img.kaLegend = <span class="reserved">this</span>;
    img.onclick = kaLegend_collapseAll;
    td.appendChild( img );
    
    tr.appendChild( td );

    td = document.createElement( <span class="literal">'td'</span> );
    td.appendChild(document.createTextNode( <span class="literal">'Layers'</span> ));

    tr.appendChild( td );
    tb.appendChild(tr);
    t.appendChild(tb);
    d.appendChild(t);
    <span class="reserved">return</span> d;
};

kaLegend.<span class="reserved">prototype</span>.createLayerHTML = <span class="reserved">function</span>( oLayer ) {
    var d, t, tb, tr, td, expander, cb, img, name;

    d = document.createElement( <span class="literal">'div'</span> );
    d.id = <span class="literal">'group_'</span> + oLayer.name;
    d.className = <span class="literal">"kaLegendLayer"</span>;
    d.oLayer=oLayer;
    name = oLayer.name;
    <span class="reserved">if</span> (name == <span class="literal">'__base__'</span>) {
        name = <span class="literal">'Base'</span>;
    }

    t = document.createElement(<span class="literal">'table'</span>);
    t.setAttribute(<span class="literal">'width'</span>,<span class="literal">'226'</span>);
    t.setAttribute(<span class="literal">'cellPadding'</span>, <span class="literal">"0"</span>);
    t.setAttribute(<span class="literal">'cellSpacing'</span>, <span class="literal">"0"</span>);
    t.setAttribute(<span class="literal">'border'</span>, <span class="literal">"0"</span>);

    tb = document.createElement( <span class="literal">'tbody'</span> );
    tr = document.createElement(<span class="literal">'tr'</span>);
    td = document.createElement(<span class="literal">'td'</span>);
    td.setAttribute( <span class="literal">"width"</span>, <span class="literal">"9"</span>);
    
    expander = document.createElement( <span class="literal">'img'</span> );
    expander.src = <span class="literal">'images/collapse.png'</span>;
    expander.layerName = oLayer.name;
    expander.id = <span class="literal">'expander_'</span>+oLayer.name;
    expander.onclick = kaLegend_expander;
    expander.expanded = true;
    
    <span class="reserved">this</span>.expanders.push( expander );
    
    td.appendChild( expander );
    
    tr.appendChild(td);
    
    <span class="comment">// layer visibility checkboxes</span>
    <span class="comment">// TODO: convert to images</span>
    td = document.createElement(<span class="literal">'td'</span>);
    td.width = <span class="literal">'22'</span>;
    <span class="reserved">if</span> (oLayer.name != <span class="literal">'__base__'</span>) {
        cb = document.createElement( <span class="literal">'input'</span> );
        cb.type = <span class="literal">'checkbox'</span>;
        cb.name = <span class="literal">'layerVisCB'</span>;
        cb.value = oLayer.name;
        cb.checked = oLayer.visible;
        cb.kaLegend = <span class="reserved">this</span>;
        cb.oLayer = oLayer;
        cb.onclick = kaLegend_toggleLayerVisibility;
        <span class="reserved">this</span>.queryCBs.push(cb);
        td.appendChild( cb );
    }
    <span class="reserved">else</span> {
        td.innerHTML = <span class="literal">'&amp;nbsp;'</span>;
    }
    tr.appendChild(td);
	
	var oMap = <span class="reserved">this</span>.kaMap.getCurrentMap();
    var aLayers = oMap.getAllLayers();
	
	<span class="comment">//Choose if you want base element to be movable (comment on line or the other)</span>
	<span class="comment">//not movable</span>
    <span class="comment">//if (oLayer.name != '__base__')</span>
	<span class="comment">// movable	 </span>
    <span class="reserved">if</span> (aLayers.length &gt; 1) {
        <span class="comment">//OPACITY IMAGES</span>
        td = document.createElement(<span class="literal">'td'</span>);
        td.width = <span class="literal">'19'</span>;
        img = document.createElement( <span class="literal">'img'</span> );
        img.src = <span class="literal">'images/sun_white.png'</span>;
        img.width = <span class="literal">'7'</span>;
        img.alt = <span class="literal">"Decrease layer opacity"</span>;
        img.title = <span class="literal">"Decrease layer opacity"</span>;
        img.style.cursor =<span class="literal">'crosshair'</span>;
        img.kaLegend = <span class="reserved">this</span>;
        img.oLayer = oLayer;
        img.onclick = kaLegend_opacityDown;
        td.appendChild( img );
        img = document.createElement( <span class="literal">'img'</span> );
        img.src = <span class="literal">'images/sun_grey.png'</span>;
        img.width = <span class="literal">'7'</span>;
        img.style.marginLeft = <span class="literal">'2px'</span>;
        img.alt = <span class="literal">"Increase layer opacity"</span>;
        img.title = <span class="literal">"Increase layer opacity"</span>;
        img.style.cursor =<span class="literal">'crosshair'</span>;
        img.kaLegend = <span class="reserved">this</span>;
        img.oLayer = oLayer;
        img.onclick = kaLegend_opacityUp;
        td.appendChild( img );
        tr.appendChild(td);
        
        <span class="comment">//SHIFT LAYERS UP DOWN</span>
        td = document.createElement(<span class="literal">'td'</span>);
        td.width = <span class="literal">'10'</span>;
        td.style.padding = <span class="literal">'1px'</span>;
        
        img = document.createElement( <span class="literal">'img'</span> );
        img.src = <span class="literal">'images/arrow_up.png'</span>;
        img.width = <span class="literal">'10'</span>;
        img.height = <span class="literal">'8'</span>;
        img.style.marginBottom = <span class="literal">'2px'</span>;
        img.alt = <span class="literal">"Shift Layer Up"</span>;
        img.title = <span class="literal">"Shift Layer Up"</span>;
        img.style.cursor =<span class="literal">'crosshair'</span>;
        img.kaLegend = <span class="reserved">this</span>;
        img.oLayer = oLayer;
        img.myDiv = d;
        img.onclick = kaLegend_moveLayerUp;
        td.appendChild( img );
        
        img = document.createElement( <span class="literal">'img'</span> );
        img.src = <span class="literal">'images/arrow_down.png'</span>;
        img.width = <span class="literal">'10'</span>;
        img.height = <span class="literal">'8'</span>;
        img.alt = <span class="literal">"Shift Layer Down"</span>;
        img.title = <span class="literal">"Shift Layer Down"</span>;
        img.style.cursor =<span class="literal">'crosshair'</span>;
        img.kaLegend = <span class="reserved">this</span>;
        img.oLayer = oLayer;
        img.myDiv = d;
        img.onclick = kaLegend_moveLayerDown;
        td.appendChild( img );
        
        tr.appendChild(td);
    }

    <span class="comment">//layer queryable images</span>
    td = document.createElement(<span class="literal">'td'</span>);
    td.width = <span class="literal">'14'</span>;
    
    img = document.createElement( <span class="literal">'img'</span> );
    img.width = <span class="literal">'14'</span>;
    img.height = <span class="literal">'14'</span>;
    <span class="reserved">if</span> (oLayer.queryable) {
        <span class="reserved">if</span> (oLayer.isQueryable()) {
            img.src = <span class="literal">'images/icon_query_on.png'</span>;
        } <span class="reserved">else</span> {
            img.src = <span class="literal">'images/icon_query_off.png'</span>;
        }
        img.onmouseover = kaLegend_queryOnMouseOver;
        img.onmouseout = kaLegend_queryOnMouseOut;
        img.onclick = kaLegend_queryOnClick;
        img.oLayer = oLayer;
    } <span class="reserved">else</span> {
        img.src = <span class="literal">'images/icon_query_x.png'</span>;
    }
        
    td = document.createElement( <span class="literal">'td'</span> );
    td.appendChild(img);
    td.width = <span class="literal">'16'</span>;
    tr.appendChild(td);
    td = document.createElement( <span class="literal">'td'</span> );
    td.innerHTML = name;
    tr.appendChild(td);
    tb.appendChild(tr);
    
    t.appendChild( tb );
    d.appendChild(t);
    
    img = document.createElement( <span class="literal">'img'</span> );
    img.id = <span class="literal">'legendImg_'</span> + oLayer.name;
    img.src = <span class="reserved">this</span>.urlBase +  <span class="literal">'legend.php?map='</span>+<span class="reserved">this</span>.kaMap.currentMap+<span class="literal">'&amp;scale='</span>+<span class="reserved">this</span>.kaMap.getCurrentScale()+<span class="literal">'&amp;g='</span>+oLayer.name;
	<span class="comment">/*modificato da kappu, nel cvs dimentica di aggiungere immagine */</span> 
	d.appendChild(img);
    expander.expandable = img;
    oLayer.kaLegendObj = d;
    kaLegend_expander.apply( expander );
	<span class="comment">//adedd by cappu</span>
	<span class="reserved">this</span>.setOnOffLayer(oLayer,oLayer.isVisible);   
};

<span class="reserved">function</span> kaLegend_toggleLayerQueryable() {
    <span class="reserved">this</span>.kaLegend.kaMap.setLayerQueryable( <span class="reserved">this</span>.value, <span class="reserved">this</span>.checked );
};

<span class="reserved">function</span> kaLegend_queryOnMouseOver() {
    <span class="reserved">if</span> (<span class="reserved">this</span>.oLayer.queryable) {
        <span class="reserved">this</span>.src = <span class="literal">'images/icon_query_over.png'</span>;
    }
};

<span class="reserved">function</span> kaLegend_queryOnMouseOut() {
    <span class="reserved">if</span> (<span class="reserved">this</span>.oLayer.queryable) {
        <span class="reserved">if</span> (<span class="reserved">this</span>.oLayer.isQueryable()) {
            <span class="reserved">this</span>.src = <span class="literal">'images/icon_query_on.png'</span>;
        } <span class="reserved">else</span> {
            <span class="reserved">this</span>.src = <span class="literal">'images/icon_query_off.png'</span>;
        }
    }
};

<span class="reserved">function</span> kaLegend_queryOnClick() {
    <span class="reserved">if</span> (<span class="reserved">this</span>.oLayer.queryable) {
        <span class="reserved">if</span> (<span class="reserved">this</span>.oLayer.isQueryable()) {
            <span class="reserved">this</span>.oLayer.setQueryable( false );
            <span class="reserved">this</span>.src = <span class="literal">'images/icon_query_off.png'</span>;
        } <span class="reserved">else</span> {
            <span class="reserved">this</span>.oLayer.setQueryable( true );
            <span class="reserved">this</span>.src = <span class="literal">'images/icon_query_on.png'</span>;
        }
    }
};

<span class="reserved">function</span> kaLegend_toggleLayerVisibility() {
    <span class="reserved">this</span>.kaLegend.kaMap.setLayerVisibility( <span class="reserved">this</span>.value, <span class="reserved">this</span>.checked );
};

<span class="reserved">function</span> kaLegend_expander() {
    <span class="reserved">this</span>.expanded = !<span class="reserved">this</span>.expanded;
    
    <span class="reserved">this</span>.src = (<span class="reserved">this</span>.expanded)?<span class="literal">'images/collapse.png'</span>:<span class="literal">'images/expand.png'</span>;
    <span class="reserved">this</span>.expandable.style.display = (<span class="reserved">this</span>.expanded)?<span class="literal">'block'</span>:<span class="literal">'none'</span>;
};

<span class="reserved">function</span> kaLegend_expandAll() {
    var kaLeg = <span class="reserved">this</span>.kaLegend;
    <span class="reserved">for</span> (var i=0; i&lt;kaLeg.expanders.length; i++) {
        kaLeg.expanders[i].expanded = false;
        kaLegend_expander.apply( kaLeg.expanders[i] );
    }
};

<span class="reserved">function</span> kaLegend_collapseAll() {
    var kaLeg = <span class="reserved">this</span>.kaLegend;
    <span class="reserved">if</span> (kaLeg.expanders) {
        <span class="reserved">for</span> (var i=0; i&lt;kaLeg.expanders.length; i++) {
            kaLeg.expanders[i].expanded = true;
            kaLegend_expander.apply( kaLeg.expanders[i] );
        }
    }
};


<span class="reserved">function</span> kaLegend_opacityDown() {
    var opc;
    opc=<span class="reserved">this</span>.oLayer.opacity-10;
    <span class="reserved">this</span>.kaLegend.kaMap.setLayerOpacity(<span class="reserved">this</span>.oLayer.name, opc );  
};

<span class="reserved">function</span> kaLegend_opacityUp() {    
    var opc;
    opc=<span class="reserved">this</span>.oLayer.opacity+10;
    <span class="reserved">this</span>.kaLegend.kaMap.setLayerOpacity(<span class="reserved">this</span>.oLayer.name, opc );
};

<span class="comment">/*added by cappu used to hide layer not visible at current scala*/</span>
kaLegend.<span class="reserved">prototype</span>.setOnOffLayer = <span class="reserved">function</span>(l) {
    <span class="reserved">if</span> (l.isVisible()) {
        <span class="reserved">if</span> (l.kaLegendObj) {
            l.kaLegendObj.style.display=<span class="literal">'block'</span>;        
        } 
    } <span class="reserved">else</span> {
        <span class="reserved">if</span>(l.kaLegendObj) {
            l.kaLegendObj.style.display=<span class="literal">'none'</span>;
        }
    }
};

<span class="comment">/**
* kaLegend_moveLayerDown 
* About a specific Group of layer, it moves the corresponding Legend div and 
*  the Viewport div to the next one
* <span class="attrib">@private</span> 
* <span class="attrib">@author</span> Lorenzo Becchi
*/</span>

<span class="reserved">function</span> kaLegend_moveLayerDown() {
    var myLayer= <span class="reserved">this</span>.oLayer;
    var leg=<span class="reserved">this</span>.myDiv.parentNode;
    var myDiv = <span class="reserved">this</span>.myDiv;
    var lowerDiv = findLowerDiv(myDiv);
    
    <span class="reserved">if</span>(lowerDiv &amp;&amp; lowerDiv.className==<span class="literal">'kaLegendLayer'</span>) {
        <span class="comment">//search correspondant checbox to prevent IE uncheck on move bug</span>
        var aCheckbox = document.getElementsByTagName(<span class="literal">'input'</span>);
        var checkboxStatusUp=null;
        var checkboxStatusDown=null;
        var checkboxUp=null;
        var checkboxDown=null;
        <span class="reserved">for</span>(var i=0;i&lt;aCheckbox.length;i++) {
            var inputTag = aCheckbox[i];
            <span class="reserved">if</span>(inputTag.value == myDiv.id.replace(/\bgroup_/, <span class="literal">''</span>)) {
                checkboxUp = inputTag;
                checkboxStatusUp = checkboxUp.checked;
            }
            <span class="reserved">if</span>(inputTag.value == lowerDiv.id.replace(/\bgroup_/, <span class="literal">''</span>)) {
                checkboxDown =inputTag;
                checkboxStatusDown = inputTag.checked;
            }
        }
        
        <span class="comment">// move legend group div  (need to do it two allow hidden layers syncing)</span>
        var proxyMy = myDiv.cloneNode(true);
        var proxyLower = lowerDiv.cloneNode(true);
        myDiv.parentNode.insertBefore( proxyMy , myDiv );
        myDiv.parentNode.insertBefore( proxyLower , lowerDiv );
        myDiv.parentNode.replaceChild( lowerDiv , proxyMy );
        myDiv.parentNode.replaceChild( myDiv , proxyLower );
        
        <span class="comment">//confirm checbox status to prevent IE uncheck on move bug</span>
        <span class="reserved">if</span>(checkboxUp)checkboxUp.checked = checkboxStatusUp;
        <span class="reserved">if</span>(checkboxDown)checkboxDown.checked = checkboxStatusDown;
	
		<span class="comment">//added by cappu,set zindex order of div layer in vieport</span>
		<span class="reserved">for</span>  (i=0,n=leg.childNodes.length;i&lt; leg.childNodes.length;i++) {
			var child= leg.childNodes[i];
			<span class="reserved">if</span>(child &amp;&amp; child.className==<span class="literal">'kaLegendLayer'</span>) {
				child.oLayer.zIndex=(n);
				n--;
			}
		}
		
		<span class="comment">//call function to redrow</span>
		<span class="reserved">this</span>.kaLegend.kaMap.setMapLayers();
    } <span class="reserved">else</span> {
        alert(<span class="literal">'this layer can\'</span>t go farther down<span class="literal">');
    } 
};

/**
 * kaLegend_moveLayerUp
 * About a specific Group of layer, it moves the corresponding Legend div and 
 * the  Viewport div to the previous one
 * @private 
 * @author Lorenzo Becchi
 */
function kaLegend_moveLayerUp() {
    var myLayer= this.oLayer;
    var leg=this.myDiv.parentNode;
    var myDiv = this.myDiv;
    var upperDiv = findUpperDiv(myDiv);
    
     if(upperDiv &amp;&amp; upperDiv.className=='</span>kaLegendLayer<span class="literal">') {
        //search correspondant checbox to prevent IE uncheck on move bug
        var aCheckbox = document.getElementsByTagName('</span>input<span class="literal">');
        var checkboxStatusUp=null;
        var checkboxStatusDown=null;
        var checkboxUp=null;
        var checkboxDown=null;
        for(var i=0;i&lt;aCheckbox.length;i++) {
            var inputTag = aCheckbox[i];
            if(inputTag.value == upperDiv.id.replace(/\bgroup_/, '</span><span class="literal">')) {
                checkboxUp = inputTag;
                checkboxStatusUp = checkboxUp.checked;
            }
            if(inputTag.value == myDiv.id.replace(/\bgroup_/, '</span><span class="literal">')) {
                checkboxDown =inputTag;
                checkboxStatusDown = inputTag.checked;
            }
        }
        
        // switch legend groups div (need to do it two allow hidden layers syncing)
        var proxyMy = myDiv.cloneNode(true);
        var proxyUpper = upperDiv.cloneNode(true);      
        myDiv.parentNode.insertBefore( proxyMy , myDiv );
        myDiv.parentNode.insertBefore( proxyUpper , upperDiv );
        myDiv.parentNode.replaceChild( upperDiv , proxyMy );
        myDiv.parentNode.replaceChild( myDiv , proxyUpper );
        
        //confirm checbox status to prevent IE uncheck on move bug
        if(checkboxUp)checkboxUp.checked = checkboxStatusUp;
        if(checkboxDown)checkboxDown.checked = checkboxStatusDown;
		
		//added by cappu,set zindex order of div layer in vieport
		for  (i=0,n=leg.childNodes.length;i&lt; leg.childNodes.length;i++) {
		    var child= leg.childNodes[i];
		    if(child &amp;&amp; child.className=='</span>kaLegendLayer<span class="literal">') {
				child.oLayer.zIndex=(n);
				n--;
			}
		}
		//call function to redrow
		this.kaLegend.kaMap.setMapLayers();
    } else {
        alert('</span><span class="reserved">this</span> layer can\<span class="literal">'t go farther up'</span>);
    }
};

<span class="comment">/**
* findLowerDiv
* find recursively nextSibling in legend list
* <span class="attrib">@private</span> 
* <span class="attrib">@author</span> Lorenzo Becchi
*/</span>
<span class="reserved">function</span> findLowerDiv(div) {
	lDiv = div.nextSibling;
	<span class="reserved">if</span>(lDiv &amp;&amp; lDiv.className==<span class="literal">'kaLegendLayer'</span> &amp;&amp; lDiv.style.display==<span class="literal">'none'</span>) {
		findLowerDiv(lDiv);
	}
	<span class="reserved">return</span> lDiv;
};
<span class="comment">/**
* findUpperDiv
* find recursively previousSibling in legend list
* <span class="attrib">@private</span> 
* <span class="attrib">@author</span> Lorenzo Becchi
*/</span>
<span class="reserved">function</span> findUpperDiv(div){
	uDiv = div.previousSibling;
	<span class="reserved">if</span>(uDiv &amp;&amp; uDiv.className==<span class="literal">'kaLegendLayer'</span> &amp;&amp; uDiv.style.display==<span class="literal">'none'</span>){
		findUpperDiv(uDiv);
	}
	<span class="reserved">return</span> uDiv;
}</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>ka-Map</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Wed Mar 15 10:50:59 2006</div>
</body>
</html>
